<template>
  <p-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel">
    <p-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <p-form :form="form">
        <p-row>

		  <p-col  :span="8">
			<p-form-item label="异常物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<f-popup
						contextPath="basic-business"
						v-decorator="['mcode', validatorRules.mcode]"
						:trigger-change="true"
						org-fields="mid,mcode,mname,sprc,mexplain"
						dest-fields="mid,mid,mcode,mname,sprc"
						code="mes_ba_cpinfo_main"
						@callback="popupCallback"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input readOnly v-decorator="[ 'mname', validatorRules.mname]" placeholder="请输入异常物料名称"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常物料规格型号" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input readOnly v-decorator="[ 'sprc', validatorRules.sprc]" placeholder="请输入异常物料规格型号"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常物料描述" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input readOnly v-decorator="[ 'mexplain', validatorRules.mexplain]" placeholder="请输入异常物料描述"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-dict-select-tag  type="list" v-decorator="['mtype', validatorRules.mtype]" :trigger-change="true" dictCode="mat_category_id" placeholder="请选择异常类型"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="工序工单编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'mobillno', validatorRules.mobillno]" placeholder="请输入工序工单编号"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="工单数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'moqty', validatorRules.moqty]" placeholder="请输入工单数量"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常二级工序编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'processTwocode', validatorRules.processTwocode]" placeholder="请输入异常二级工序编码"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常工站 " :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'workstation', validatorRules.workstation]" placeholder="请输入异常工站 "></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="故障大类" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-dict-select-tag  type="list" v-decorator="['faultTypes', validatorRules.faultTypes]" :trigger-change="true" dictCode="mes_fault_types" placeholder="请选择故障大类"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="故障小类" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-dict-select-tag  type="list" v-decorator="['smallFaultClass', validatorRules.smallFaultClass]" :trigger-change="true" dictCode="mes_small_fault_class" placeholder="请选择故障小类"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常描设备编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'deviceno', validatorRules.deviceno]" placeholder="请输入异常描设备编码"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常描述 " :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'abnormalDescription', validatorRules.abnormalDescription]" placeholder="请输入异常描述 "></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="附件上传" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-upload v-decorator="['fileurl', validatorRules.fileurl]" :trigger-change="true"></j-upload>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常SN" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'abnormalSn', validatorRules.abnormalSn]" placeholder="请输入异常SN"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常发起人" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'abnormalPerson', validatorRules.abnormalPerson]" placeholder="请输入异常发起人"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="异常发起时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date    placeholder="请选择异常发起时间" v-decorator="[ 'initiationTime', validatorRules.initiationTime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="接收人" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'recipient', validatorRules.recipient]" placeholder="请输入接收人"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="线体" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input readOnly v-decorator="[ 'linename', validatorRules.linename]" placeholder="请输入线体"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="线体编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<f-popup
						contextPath="basic-business"
						v-decorator="['lineno', validatorRules.lineno]"
						:trigger-change="true"
						org-fields="lineid,lineno,linename,workroomid,workroomno,workroomname"
						dest-fields="lineid,lineno,linename,workroomid,workroomno,workroomname"
						code="line_select"
						@callback="popupCallback"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="班组" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'classname', validatorRules.classname]" placeholder="请输入班组"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="班组编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<f-popup
						contextPath="basic-business"
						v-decorator="['classno', validatorRules.classno]"
						:trigger-change="true"
						org-fields="classno,classname"
						dest-fields="classno,classname"
						code="mes_hr_q_classinfo"
						@callback="popupCallback"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input  v-decorator="[ 'remark', validatorRules.remark]" placeholder="请输入备注"></p-input>
			</p-form-item>
		  </p-col>


        </p-row>
      </p-form>

      <!-- 子表单区域 -->
      <p-tabs v-model="activeKey" @change="handleChangeTabs">
        <p-tab-pane tab="异常记录" :key="refKeys[0]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[0]"
            :loading="mesMfExceptionRecordTable.loading"
            :columns="mesMfExceptionRecordTable.columns"
            :dataSource="mesMfExceptionRecordTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="长期措施" :key="refKeys[1]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[1]"
            :loading="mesMfLongTermMeasureTable.loading"
            :columns="mesMfLongTermMeasureTable.columns"
            :dataSource="mesMfLongTermMeasureTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="措施验证（PQE)" :key="refKeys[2]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[2]"
            :loading="mesMfVerificationPqeTable.loading"
            :columns="mesMfVerificationPqeTable.columns"
            :dataSource="mesMfVerificationPqeTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="临时措施维护" :key="refKeys[3]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[3]"
            :loading="mesMfMaintenanceMeasuresTable.loading"
            :columns="mesMfMaintenanceMeasuresTable.columns"
            :dataSource="mesMfMaintenanceMeasuresTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="原因分析及长期措施" :key="refKeys[4]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[4]"
            :loading="mesMfReasonAnalysisTable.loading"
            :columns="mesMfReasonAnalysisTable.columns"
            :dataSource="mesMfReasonAnalysisTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="异常处置" :key="refKeys[5]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[5]"
            :loading="mesMfExceptionalHandlingTable.loading"
            :columns="mesMfExceptionalHandlingTable.columns"
            :dataSource="mesMfExceptionalHandlingTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="更换物料信息" :key="refKeys[6]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[6]"
            :loading="mesMfChangeMaterialInformationTable.loading"
            :columns="mesMfChangeMaterialInformationTable.columns"
            :dataSource="mesMfChangeMaterialInformationTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
        <p-tab-pane tab="PQE判定" :key="refKeys[7]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[7]"
            :loading="mesMfPqeJudgementTable.loading"
            :columns="mesMfPqeJudgementTable.columns"
            :dataSource="mesMfPqeJudgementTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </p-tab-pane>
        
      </p-tabs>

    </p-spin>
  </p-modal>
</template>

<script>

  import pick from 'lodash.pick'
  import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'  
  import JUpload from '@/components/jeecg/JUpload'
  import JDictSelectTag from "@/components/dict/JDictSelectTag"

  export default {
    name: 'MesMfAbnormalCallModal',
    mixins: [JEditableTableMixin],
    components: {
      JDate,
      JUpload,
      JDictSelectTag,
    },
    data() {
      return {
        labelCol: {
          span: 6
        },
        wrapperCol: {
          span: 16
        },
        labelCol2: {
          span: 3
        },
        wrapperCol2: {
          span: 20
        },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        validatorRules: {
          mcode: {rules: [
            {required: true, message: '请输入异常物料编码!'},
          ]},
          mname: {rules: [
            {required: true, message: '请输入异常物料名称!'},
          ]},
          sprc: {rules: [
          ]},
          mexplain: {rules: [
          ]},
          mtype: {rules: [
            {required: true, message: '请输入异常类型!'},
          ]},
          mobillno: {rules: [
            {required: true, message: '请输入工序工单编号!'},
          ]},
          moqty: {rules: [
            {required: true, message: '请输入工单数量!'},
          ]},
          processTwocode: {rules: [
          ]},
          workstation: {rules: [
          ]},
          faultTypes: {rules: [
            {required: true, message: '请输入故障大类!'},
          ]},
          smallFaultClass: {rules: [
            {required: true, message: '请输入故障小类!'},
          ]},
          deviceno: {rules: [
            {required: true, message: '请输入异常描设备编码!'},
          ]},
          abnormalDescription: {rules: [
            {required: true, message: '请输入异常描述 !'},
          ]},
          fileurl: {rules: [
          ]},
          abnormalSn: {rules: [
            {required: true, message: '请输入异常SN!'},
          ]},
          abnormalPerson: {rules: [
            {required: true, message: '请输入异常发起人!'},
          ]},
          initiationTime: {rules: [
            {required: true, message: '请输入异常发起时间!'},
          ]},
          recipient: {rules: [
            {required: true, message: '请输入接收人!'},
          ]},
          linename: {rules: [
            {required: true, message: '请输入线体!'},
          ]},
          lineno: {rules: [
          ]},
          classname: {rules: [
          ]},
          classno: {rules: [
          ]},
          remark: {rules: [
          ]},
        },
        refKeys: ['mesMfExceptionRecord', 'mesMfLongTermMeasure', 'mesMfVerificationPqe', 'mesMfMaintenanceMeasures', 'mesMfReasonAnalysis', 'mesMfExceptionalHandling', 'mesMfChangeMaterialInformation', 'mesMfPqeJudgement', ],
        tableKeys:['mesMfExceptionRecord', 'mesMfLongTermMeasure', 'mesMfVerificationPqe', 'mesMfMaintenanceMeasures', 'mesMfReasonAnalysis', 'mesMfExceptionalHandling', 'mesMfChangeMaterialInformation', 'mesMfPqeJudgement', ],
        activeKey: 'mesMfExceptionRecord',
        // 异常记录
        mesMfExceptionRecordTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '异常记录',
              key: 'exceptionRecord',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 长期措施
        mesMfLongTermMeasureTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '措施',
              key: 'measuress',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '措施预计完成时间',
              key: 'measuretime',
              type: FormTypes.date,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 措施验证（PQE)
        mesMfVerificationPqeTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '措施验证是否通过',
              key: 'mesPass',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '质控更改事务单号',
              key: 'mesOrder',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '纠结措施验证说明',
              key: 'mesExplain',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 临时措施维护
        mesMfMaintenanceMeasuresTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '责任人',
              key: 'personCharge',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '退回原因',
              key: 'returnReason',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '临时措施',
              key: 'provisionalMeasures',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '临时措施验证人',
              key: 'identifier',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 原因分析及长期措施
        mesMfReasonAnalysisTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '原因分析',
              key: 'causeAnalysis',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '故障原因大类',
              key: 'reasonCategories',
              type: FormTypes.select,
              dictCode: 'mes_reason_categories',
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '故障原因小类',
              key: 'smallClass',
              type: FormTypes.select,
              dictCode: 'mes_small_class',
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '附件',
              key: 'accessory',
              type: FormTypes.file,
              token:true,
              responseName: 'message',
              width: '200px',
              placeholder: '请选择文件',
              defaultValue: '',
            },
            {
              title: '原因分析拟定人',
              key: 'analysisDraftsman',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '操作时间',
              key: 'operationTime',
              type: FormTypes.date,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 异常处置
        mesMfExceptionalHandlingTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '异常是否成立',
              key: 'exceptionEstablish',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '不成立原因',
              key: 'untenableReason',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '是否推送工艺协助',
              key: 'push',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '工艺协助人员',
              key: 'processAssistant',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '工艺方案',
              key: 'processProgram',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '处置方案',
              key: 'disposalConcept',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // 更换物料信息
        mesMfChangeMaterialInformationTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '故障物料SN码',
              key: 'snCode',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '单盘工单号（外协）',
              key: 'outsource',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '故障物料ERP',
              key: 'faultMaterialErp',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '物料编码',
              key: 'mcode',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '物料描述/型号',
              key: 'mexplain',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '故障物料类别',
              key: 'faultMaterialType',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '故障物料供应商',
              key: 'supplierFaultyMaterials',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '故障数量',
              key: 'theFaultQty',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        // PQE判定
        mesMfPqeJudgementTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '异常是否成立',
              key: 'exceptionFounded',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '不成立原因',
              key: 'untenableReason',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '异常等级',
              key: 'abnormalLevel',
              type: FormTypes.select,
              dictCode: 'mes_abnormal_level',
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '是否返工',
              key: 'rework',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '是否切线',
              key: 'tangent',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '是否锁定产品',
              key: 'lockProducts',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '锁定单号',
              key: 'lockOrder',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '生产策略',
              key: 'productionStrategy',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
            {
              title: '问题处理人',
              key: 'problemHandler',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '异常信息推送人员',
              key: 'pushPersonnel',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
            },
          ]
        },
        url: {
          add: '/mes-manufacture/auto/mesMfAbnormalCall/add',
          edit: '/mes-manufacture/auto/mesMfAbnormalCall/edit',
          mesMfExceptionRecord: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfExceptionRecordByMainId'
          },
          mesMfLongTermMeasure: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfLongTermMeasureByMainId'
          },
          mesMfVerificationPqe: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfVerificationPqeByMainId'
          },
          mesMfMaintenanceMeasures: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfMaintenanceMeasuresByMainId'
          },
          mesMfReasonAnalysis: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfReasonAnalysisByMainId'
          },
          mesMfExceptionalHandling: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfExceptionalHandlingByMainId'
          },
          mesMfChangeMaterialInformation: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfChangeMaterialInformationByMainId'
          },
          mesMfPqeJudgement: {
            list: '/mes-manufacture/auto/mesMfAbnormalCall/queryMesMfPqeJudgementByMainId'
          },
        }
      }
    },
    methods: {
      getAllTable() {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        let fieldval = pick(this.model,'mcode','mname','sprc','mexplain','mtype','mobillno','moqty','processTwocode','workstation','faultTypes','smallFaultClass','deviceno','abnormalDescription','fileurl','abnormalSn','abnormalPerson','initiationTime','recipient','linename','lineno','classname','classno','createBy','createTime','updateBy','updateTime','remark')
        this.$nextTick(() => {
          this.form.setFieldsValue(fieldval)
        })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.mesMfExceptionRecord.list, params, this.mesMfExceptionRecordTable)
          this.requestSubTableData(this.url.mesMfLongTermMeasure.list, params, this.mesMfLongTermMeasureTable)
          this.requestSubTableData(this.url.mesMfVerificationPqe.list, params, this.mesMfVerificationPqeTable)
          this.requestSubTableData(this.url.mesMfMaintenanceMeasures.list, params, this.mesMfMaintenanceMeasuresTable)
          this.requestSubTableData(this.url.mesMfReasonAnalysis.list, params, this.mesMfReasonAnalysisTable)
          this.requestSubTableData(this.url.mesMfExceptionalHandling.list, params, this.mesMfExceptionalHandlingTable)
          this.requestSubTableData(this.url.mesMfChangeMaterialInformation.list, params, this.mesMfChangeMaterialInformationTable)
          this.requestSubTableData(this.url.mesMfPqeJudgement.list, params, this.mesMfPqeJudgementTable)
        }
      },
      /** 整理成formData */
      classifyIntoFormData(allValues) {
        let main = Object.assign(this.model, allValues.formValue)

        return {
          ...main, // 展开
          mesMfExceptionRecordList: allValues.tablesValue[0].values,
          mesMfLongTermMeasureList: allValues.tablesValue[1].values,
          mesMfVerificationPqeList: allValues.tablesValue[2].values,
          mesMfMaintenanceMeasuresList: allValues.tablesValue[3].values,
          mesMfReasonAnalysisList: allValues.tablesValue[4].values,
          mesMfExceptionalHandlingList: allValues.tablesValue[5].values,
          mesMfChangeMaterialInformationList: allValues.tablesValue[6].values,
          mesMfPqeJudgementList: allValues.tablesValue[7].values,
        }
      },
      validateError(msg){
        this.$message.error(msg)
      },
     popupCallback(row){
       this.form.setFieldsValue(pick(row,'mcode','mname','sprc','mexplain','mtype','mobillno','moqty','processTwocode','workstation','faultTypes','smallFaultClass','deviceno','abnormalDescription','fileurl','abnormalSn','abnormalPerson','initiationTime','recipient','linename','lineno','classname','classno','createBy','createTime','updateBy','updateTime','remark'))
     },

    }
  }
</script>

<style scoped>
</style>
